/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package armado;

/**
 *
 * @author Alumno
 */
public class cal extends javax.swing.JFrame {

    /**
     * Creates new form aleatorios
     */
    public cal() {
        initComponents();      
        setSize(400, 400);
        setLocationRelativeTo(null);
        btn9.setVisible(false);
        
        
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        btn1 = new javax.swing.JButton();
        btn2 = new javax.swing.JButton();
        btn3 = new javax.swing.JButton();
        btn4 = new javax.swing.JButton();
        btn5 = new javax.swing.JButton();
        btn6 = new javax.swing.JButton();
        btn7 = new javax.swing.JButton();
        btn8 = new javax.swing.JButton();
        btn9 = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setBackground(new java.awt.Color(0, 0, 255));
        getContentPane().setLayout(new java.awt.GridLayout(3, 3));

        btn1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/armado/Penguins.jpg"))); // NOI18N
        btn1.setText("1");
        btn1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn1ActionPerformed(evt);
            }
        });
        getContentPane().add(btn1);

        btn2.setText("2");
        btn2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn2ActionPerformed(evt);
            }
        });
        getContentPane().add(btn2);

        btn3.setText("3");
        btn3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn3ActionPerformed(evt);
            }
        });
        getContentPane().add(btn3);

        btn4.setText("4");
        btn4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn4ActionPerformed(evt);
            }
        });
        getContentPane().add(btn4);

        btn5.setText("5");
        btn5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn5ActionPerformed(evt);
            }
        });
        getContentPane().add(btn5);

        btn6.setText("6");
        btn6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn6ActionPerformed(evt);
            }
        });
        getContentPane().add(btn6);

        btn7.setText("7");
        btn7.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn7ActionPerformed(evt);
            }
        });
        getContentPane().add(btn7);

        btn8.setText("8");
        btn8.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn8ActionPerformed(evt);
            }
        });
        getContentPane().add(btn8);

        btn9.setText("9");
        btn9.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn9ActionPerformed(evt);
            }
        });
        getContentPane().add(btn9);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btn2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn2ActionPerformed
        // TODO add your handling code here:
         if(btn3.isVisible()==false){
        btn3.setText(btn2.getText());
        btn2.setVisible(false);
        btn3.setVisible(true);
        }
        if(btn1.isVisible()==false){
            btn1.setText(btn2.getText());
            btn2.setVisible(false);
            btn1.setVisible(true);
                          }
        
        if(btn5.isVisible()==false){
            btn5.setText(btn2.getText());
            btn2.setVisible(false);
            btn5.setVisible(true);
        
        
        }
    }//GEN-LAST:event_btn2ActionPerformed

    private void btn9ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn9ActionPerformed
        // TODO add your handling code here:
        if(btn6.isVisible()==false){
        btn6.setText(btn9.getText());
        btn9.setVisible(false);
        btn6.setVisible(true);
        }
        if(btn8.isVisible()==false){
        btn8.setText(btn9.getText());
        btn9.setVisible(false);
        btn8.setVisible(true);
        }
    }//GEN-LAST:event_btn9ActionPerformed

    private void btn3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn3ActionPerformed
        // TODO add your handling code here:
         if(btn2.isVisible()==false){
        btn2.setText(btn3.getText());
        btn3.setVisible(false);
        btn2.setVisible(true);
        }
        if(btn6.isVisible()==false){
            btn6.setText(btn3.getText());
            btn3.setVisible(false);
            btn6.setVisible(true);
                          }
        
       
    }//GEN-LAST:event_btn3ActionPerformed

    private void btn4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn4ActionPerformed
        // TODO add your handling code here:
         if(btn1.isVisible()==false){
        btn1.setText(btn4.getText());
        btn4.setVisible(false);
        btn1.setVisible(true);
        }
        if(btn5.isVisible()==false){
            btn5.setText(btn4.getText());
            btn4.setVisible(false);
            btn5.setVisible(true);
                          }
        
        if(btn7.isVisible()==false){
            btn7.setText(btn4.getText());
            btn4.setVisible(false);
            btn7.setVisible(true);
        
        
        }
    }//GEN-LAST:event_btn4ActionPerformed

    private void btn7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn7ActionPerformed
        // TODO add your handling code here:
        if(btn4.isVisible()==false){
        btn4.setText(btn7.getText());
        btn7.setVisible(false);
        btn4.setVisible(true);
        }
        if(btn8.isVisible()==false){
            btn8.setText(btn7.getText());
            btn7.setVisible(false);
            btn8.setVisible(true);
                          }
        
        
        
    }//GEN-LAST:event_btn7ActionPerformed

    private void btn6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn6ActionPerformed
        // TODO add your handling code here:
    
        if(btn3.isVisible()==false){
        btn3.setText(btn6.getText());
        btn6.setVisible(false);
        btn3.setVisible(true);
        }
        if(btn5.isVisible()==false){
            btn5.setText(btn6.getText());
            btn6.setVisible(false);
            btn5.setVisible(true);
                          }
        
        if(btn9.isVisible()==false){
            btn9.setText(btn6.getText());
            btn6.setVisible(false);
            btn9.setVisible(true);
        
        
        }
        
    }//GEN-LAST:event_btn6ActionPerformed

    private void btn8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn8ActionPerformed
        // TODO add your handling code here:
        if(btn9.isVisible()==false){
        btn9.setText(btn8.getText());
        btn8.setVisible(false);
        btn9.setVisible(true);
        }
        if(btn7.isVisible()==false){
            btn7.setText(btn8.getText());
            btn8.setVisible(false);
            btn7.setVisible(true);
                          }
        
        if(btn5.isVisible()==false){
            btn5.setText(btn8.getText());
            btn8.setVisible(false);
            btn5.setVisible(true);
        
        
        }
    }//GEN-LAST:event_btn8ActionPerformed

    private void btn1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn1ActionPerformed
        // TODO add your handling code here:
         if(btn4.isVisible()==false){
        btn4.setText(btn1.getText());
        btn1.setVisible(false);
        btn4.setVisible(true);
        }
        if(btn2.isVisible()==false){
            btn2.setText(btn1.getText());
            btn1.setVisible(false);
            btn2.setVisible(true);
                          }
        
       
    }//GEN-LAST:event_btn1ActionPerformed

    private void btn5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn5ActionPerformed
        // TODO add your handling code here:
         if(btn4.isVisible()==false){
        btn4.setText(btn5.getText());
        btn5.setVisible(false);
        btn4.setVisible(true);
         }
        if(btn2.isVisible()==false){
            btn2.setText(btn5.getText());
            btn5.setVisible(false);
            btn2.setVisible(true);
                          }
        
        if(btn6.isVisible()==false){
            btn6.setText(btn5.getText());
            btn5.setVisible(false);
            btn6.setVisible(true);
        
        }
        
        if(btn8.isVisible()==false){
            btn8.setText(btn5.getText());
            btn5.setVisible(false);
            btn8.setVisible(true);
          
                 }
    }//GEN-LAST:event_btn5ActionPerformed
           
    /**
     * @param args the command line arguments
     */
           
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btn1;
    private javax.swing.JButton btn2;
    private javax.swing.JButton btn3;
    private javax.swing.JButton btn4;
    private javax.swing.JButton btn5;
    private javax.swing.JButton btn6;
    private javax.swing.JButton btn7;
    private javax.swing.JButton btn8;
    private javax.swing.JButton btn9;
    // End of variables declaration//GEN-END:variables
    public void desordenar(){
        btn1.setText("2");
        btn2.setText("9");
        btn3.setText("4");
        btn4.setText("7");
        btn5.setText("3");
        btn6.setText("8");
        btn7.setText("1");
        btn8.setText("5");              
        btn9.setText("6");
             
             
        
    
    }
}
